package com.resp;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(urlPatterns = "/resp3",name = "resp3")
public class respond3 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 响应体 ： 字符数据 ， 字节数据
        // 尤其是 字符：需要设置编码！
        resp.setCharacterEncoding("UTF-8");

        resp.setContentType("text/html;charset=UTF-8");
        // 字符数据对应的流
        PrintWriter writer = resp.getWriter();
        writer.println("<h1>哈哈哈哈哈哈！周末了！好开心啊！</h1>");
    }
}
